$(function(){
    $.validator.setDefaults({
        ignore: []
    });
    $("#setform").validate({
        rules: {
            newpassword: {
                required: true,
                minlength: 1
            },
            confirm: {
                required: true,
                minlength: 1,
                equalTo: "#newpassword"
            }
        },
        messages: {
            newpassword: {
                required: "Please fill in the password"
            },
            confirm: {
                required: "Please fill in the password"
            }
        },
        errorPlacement: function(error, element) {
            error.appendTo(element.parent());
        }
    });
    if(dev) {
        console.info("setpassword init js");
    }
    //getData('POST',interfaces.userinfo,true,'{"token":"'+$.cookie("token")+'"}','settings');
    $('body').delegate('.save','click',function(){

        if($("#setform").validate().form()){
            //var name=$('#name').val();
            var newpassword=$('#newpassword').val();
            var confirm=$('#confirm').val();

            var data=new Object();
            data['token']=$.cookie('token');
            data['password']=newpassword;

            getData('POST',interfaces.setpassword,true,JSON.stringify(data),'setpassword');
        }

    });

});